# import requests, time
#
# url = 'https://ssr4.scrape.center/'  # 换成真实地址
# tic = time.perf_counter()
# resp = requests.get(url, timeout=10)       # 至少设 10 s，否则提前抛错
# toc = time.perf_counter()
#
# print(f'状态码 {resp.status_code}  总耗时 {toc-tic:.2f}s')
#
#
# from requests.adapters import HTTPAdapter
# from urllib3.util.retry import Retry
#
# s = requests.Session()
# retries = Retry(total=3, backoff_factor=1, status_forcelist=[500, 502, 503])
# s.mount('http://', HTTPAdapter(max_retries=retries))
#
# resp = s.get(url, timeout=10)
# print(resp.text[:200])


# import requests, time, sys
#
# url = 'https://ssr4.scrape.center/'  # 返回 1 MB 的页面
# start = time.perf_counter()
# resp = requests.get(url, timeout=20)
# elapsed = time.perf_counter() - start
#
# bytes_len = len(resp.content)
# print(f'延迟 5 s 已固定，纯下载 {bytes_len/1024:.1f} KB 耗时 {elapsed:.2f}s')
# print(f'因此真实带宽 ≈ {bytes_len*8/elapsed/1e6:.2f} Mbps')

